﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../../../Content/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../../../Content/element-plus/index.css">
  <link rel="stylesheet" href="../../../Content/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../../../styles/vue-page-common.css">
  <script src="../../../Scripts/Array.prototype.flat.js"></script>
  <script src="../../../Scripts/ResizeObserver.js"></script>
  <script src="../../../Content/vue3/vue.global.js"></script>
  <script src="../../../Content/element-plus/index.full.min.js"></script>
  <script src="../../../Content/element-plus/icons-vue.js"></script>
  <script src="../../../Content/element-plus/zh-cn.min.js"></script>
  <script src="../../../Scripts/axios.min.js"></script>
  <script src="../../../Content/nprogress/nprogress.min.js"></script>
  <script src="../../../Scripts/dayjs.min.js"></script>
  <script src="../../../Scripts/axios.config.js"></script>
  <script src="../../../Scripts/crypto-js.min.js"></script>
  <script src="../../../Scripts/secret.js"></script>
  <title>装配检验作业</title>
  <style>
    .header {
      color: #fff;
      height: 50px;
      display: flex;
      align-items: center;
      background-image: linear-gradient(to right, #1E9FFF 0%, #68e0cf 100%);
    }

    .el-form-item__label {
      font-weight: normal;
    }

    .header-text {
      font-size: 22px;
      margin-left: 10px;
      font-weight: bold;
    }

    .el-breadcrumb__inner,
    .el-breadcrumb__separator {
      font-size: 16px;
      color: #fff !important;
    }

    .card-header-icon {
      color: #1E9FFF;
      margin-right: 5px;
      font-size: 20px;
    }

    .card-header-text {
      color: #000;
      font-size: 20px;
      font-weight: bold;
    }

    .flush-btn {
      position: absolute;
      right: 0;
      top: 0;
    }

    .el-card__body,
    .el-main {
      padding: 2px;
    }

    .el-submenu__title {
      font-size: 16px;
      font-weight: bold;
    }

    .el-sub-menu__title {
      font-size: 20px;
      color: #1E9FFF;
      font-weight: bold;
    }

    .info-text {
      font-size: 16px;
      height: 36px;
      line-height: 36px;
      margin-left: 10px;
    }

    .info-text-label {
      font-weight: bold;
      padding-right: 10px;
    }

    .el-form--label-top .el-form-item__label {
      padding: 0;
    }

    .el-form-item {
      margin-bottom: 10px;
    }

    .el-tabs__item {
      font-size: 16px;
      font-weight: bold;
    }

    .item {
      display: inline-block;
      text-align: center;
      margin-right: 25px;
    }

    .item-image-container {
      min-width: 60px;
      height: 40px;
      /* border-radius: 50%; */
      /* border: 1px dashed #1E9FFF; */
      display: flex;
      justify-content: center;
      align-items: center;
      /* cursor: pointer; */
    }

    .item-text {
      font-weight: bold;
      font-size: 16px;
      color: #1E9FFF;
      margin-top: 5px;
    }

    .handle-container {
      border-radius: 4px;
      border: 1px solid #EBEEF5;
      background-image: linear-gradient(to right, #C4E6FF 0%, #fff 100%);
      margin-top: 10px;
      padding: 10px;
      box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
    }

    .item-icon {
      font-size: 35px;
      color: #1E9FFF;
      transition: all 1.5s;
      font-size: 30px;
    }

    .sub-menu-icon {
      font-size: 20px !important;
      transition: all 1.5s;
    }

    .sub-menu-icon:hover {
      transform: scale(1.3) rotate(360deg);
    }

    .item-icon:hover {
      transform: scale(1.3) rotate(360deg);
    }

    /* 覆盖菜单项样式 */
    .el-menu-item {
      padding-left: 20px !important;
    }

    .el-menu-item.is-active {
      font-weight: bold;
      color: #1E9FFF;
      border: 1px dashed #1E9FFF;
      border-radius: 10px;
      font-size: 16px;
    }

    /* 待报工 */
    #unReport .el-menu-item.is-active {
      color: #67C23A;
      border: 1px dashed #67C23A;
    }

    /* 待检验 */
    #unCheck .el-menu-item.is-active {
      color: #F56C6C;
      border: 1px dashed #F56C6C;
    }

    .el-tree-node__content {
      height: 30px !important;
    }

    .el-tree-node__content:hover {
      font-weight: bold;
      color: #409EFF;
    }

    /* 徽标 */
    .el-badge__content.is-fixed {
      top: 5px;
    }
  </style>
</head>

<body>
  <div id="app" v-cloak>
    <el-watermark :content="'RS031'"></el-watermark>
    <!-- 头部标题区域 -->
    <el-row class="header">
      <el-col :span="6">
        <div style="display: flex;align-items: center;position: relative;">
          <el-icon style="font-size: 22px;margin-left: 10px;">
            <home-filled />
          </el-icon>
          <span style="font-size: 20px;margin-left: 5px;font-weight: bold;">中国航发黎阳-制造执行系统</span>
        </div>
      </el-col>
      <el-col :span="14">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item>{{userInfo.factoryname}}</el-breadcrumb-item>
          <el-breadcrumb-item>{{userInfo.workcentername}}</el-breadcrumb-item>
          <el-breadcrumb-item>{{userInfo.teamname ? userInfo.teamname : '--'}}</el-breadcrumb-item>
        </el-breadcrumb>
      </el-col>
      <el-col :span="4" style="text-align: right;">
        <span style="margin-right:20px;">{{currentTime}}</span>
      </el-col>
    </el-row>

    <!-- 中间部分 -->
    <el-row :gutter="10" style="margin: 10px 5px;">
      <!-- 左侧 -->
      <el-col :span="4">
        <!-- 个人信息 -->
        <el-card class="box-card">
          <template #header>
            <div style="display: flex;align-items: center;position: relative;">
              <el-icon class="card-header-icon">
                <Avatar />
              </el-icon>
              <span class="card-header-text">个人信息</span>
              <el-button round class="flush-btn" @click="handleUserInfoFlushClick">
                <el-icon class="sub-menu-icon">
                  <Refresh />
                </el-icon>
                <span style="margin-left: 6px;">刷新</span>
              </el-button>
            </div>
          </template>
          <el-row :gutter="10">
            <el-col :span="8">
              <div v-if="userInfo.userimageurl">
                <el-image style="width: 105px;height: 140px;" :src="userInfo.userimageurl"
                  :preview-src-list="[userInfo.userimageurl]">
                </el-image>
              </div>
              <div v-else>
                <el-image style="width: 105px;height: 140px;border:1px dashed #1E9FFF;">
                </el-image>
              </div>
            </el-col>
            <el-col :span="16">
              <div class="info-text">
                <span class="info-text-label">姓名:</span>{{userInfo.fullname}}
              </div>
              <div class="info-text">
                <span class="info-text-label">工时分值:</span>{{worktimeInfo.txtTimeAttribute}}
              </div>
              <div class="info-text">
                <span class="info-text-label">总工时:</span>{{worktimeInfo.txtSumWorkTime}}
              </div>
              <div class="info-text">
                <span class="info-text-label">总绩效:</span>{{worktimeInfo.txtSumJX}}
              </div>
            </el-col>
          </el-row>
        </el-card>

        <!-- 我的任务 -->
        <el-card class="box-card" style="margin-top: 10px;">
          <template #header>
            <div style="display: flex;align-items: center;position: relative;">
              <el-icon class="card-header-icon">
                <Flag />
              </el-icon>
              <span class="card-header-text">我的任务</span>
              <el-button round class="flush-btn" @click="handleContainerSearchBlur(1)">
                <el-icon class="sub-menu-icon">
                  <Refresh />
                </el-icon>
                <span style="margin-left: 6px;">刷新</span>
              </el-button>
            </div>
          </template>

          <el-scrollbar :height="clientHeight">
            <el-form style="margin:10px 20px;">
              <el-form-item>
                <el-input v-model="searchObj.containername" placeholder="请扫卡或输入任务单号、订单号"
                  @blur="handleContainerSearchBlur" clearable>
                </el-input>
              </el-form-item>
            </el-form>
            <el-menu>
              <!-- 待报工 -->
              <el-sub-menu index="待报工">
                <template #title>
                  <el-icon style="color:#67C23A" class="sub-menu-icon">
                    <video-play />
                  </el-icon>
                  <el-badge :value="containerSearchScan.unReportDataRows" :max="1000" type="success">
                    <span style="font-size: 18px;color:#67C23A;">待检验</span>
                  </el-badge>
                </template>
                <el-menu-item v-for="i in containerSearchScan.notReportedList" :key="i.TOGETHERFLAG"
                  :label="i.TOGETHERFLAG" :value="i.TOGETHERFLAG" :index="i.TOGETHERFLAG" @click="selectContainerMenu">
                  <el-popover trigger="hover" placement="top" width="300">
                    <p>订单号：{{i.MFGORDERNAME}}</p>
                    <p>发动机号：{{i.MACHINE}}</p>
                    <p>件号名称：{{i.DESCRIPTION}}</p>
                    <template #reference>
                      <el-icon>
                        <info-filled />
                      </el-icon>
                    </template>
                  </el-popover>
                  {{i.TOGETHERFLAG}}【{{i.STEPNAME}}】
                </el-menu-item>
              </el-sub-menu>
              <!-- 待检验 -->
              <el-sub-menu index="待检验">
                <template #title>
                  <el-icon style="color:#F56C6C" class="sub-menu-icon">
                    <Stamp />
                  </el-icon>
                  <el-badge :value="containerSearchScan.unCheckContainerCount" :max="1000" type="danger">
                    <span style="font-size: 18px;color:#F56C6C;">已检验</span>
                  </el-badge>
                </template>
                <el-menu-item v-for="i in containerSearchScan.unCheckContainerData" :key="i.TOGETHERFLAG"
                  :label="i.TOGETHERFLAG" :value="i.TOGETHERFLAG" :index="i.TOGETHERFLAG">
                  {{i.TOGETHERFLAG}}【{{i.STEPNAME}}】
                </el-menu-item>
              </el-sub-menu>
            </el-menu>
        </el-card>
      </el-col>

      <!-- 右侧 -->
      <el-col :span="20">
        <!-- 生产报工区域 -->
        <el-card class="box-card">
          <template #header>
            <div style="display: flex;align-items: center;">
              <el-icon class="card-header-icon">
                <video-play />
              </el-icon>
              <span class="card-header-text">检验作业</span>
            </div>
          </template>
          <div style="padding: 10px;">
            <!-- 批次信息 -->
            <el-form :inline="true" :model="formData" :label-position="'top'">
              <el-form-item label="扫描任务单">
                <el-input v-model="formData.ContainerNo" style="width: 140px;" clearable></el-input>
              </el-form-item>

              <el-form-item label="发动机号">
                <el-input v-model="formData.Machine" style="width: 120px;" clearable></el-input>
              </el-form-item>

              <el-form-item label="件号">
                <el-input v-model="formData.ProductName" style="width: 120px;" clearable></el-input>
              </el-form-item>

              <el-form-item label="任务分类">
                <el-select v-model="formData.TaskType" style="width: 120px;">
                  <el-option label="全部" value=""></el-option>
                  <el-option label="订单任务" value="订单任务"></el-option>
                  <el-option label="施工单任务" value="施工单任务"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label=" ">
                <el-button type="primary" style="margin-top: 20px;" @click="queryContainerCheckData">查询</el-button>
                <el-button plain style="margin-top: 20px;" @click="qureyReset">重置</el-button>
              </el-form-item>
            </el-form>

            <el-scrollbar :height="inputHeight+125">
              <!-- 任务单单信息 -->
              <el-tabs v-model="tabfirst">
                <el-tab-pane label="任务单信息" name="first" style="width: 100%;">
                  <el-table border style="width: 100%" :data="containerList" :height="tableHeight-190"
                    ref="containerTableRef" @row-click="selectContainerRow" highlight-current-row>
                    <el-table-column type="index" width="40"></el-table-column>
                    <el-table-column prop="MACHINE" label="发动机号" width="100"></el-table-column>
                    <el-table-column prop="MFGORDERNAME" label="订单号" width="140"></el-table-column>
                    <el-table-column prop="TOGETHERFLAG" label="批次任务单号" width="180"></el-table-column>
                    <el-table-column prop="PRODUCTNAME" label="件号" width="180"></el-table-column>
                    <el-table-column prop="DESCRIPTION" label="件号名称" width="180"></el-table-column>
                    <el-table-column prop="WORKFLOWNAMEVER" label="工艺路线信息"></el-table-column>
                    <el-table-column prop="WFDESC" label="工艺路线名称" width="180"></el-table-column>
                    <el-table-column prop="STEPNAME" label="阶段" width="100"></el-table-column>
                    <el-table-column prop="PLANNEDSTARTDATE" label="计划开始时间" width="180" :formatter="dateFormatter">
                    </el-table-column>
                    <el-table-column prop="PLANNEDCOMPLETIONDATE" label="计划结束时间" width="180" :formatter="dateFormatter">
                    </el-table-column>
                  </el-table>
                  <el-pagination style="float: right;" v-model:current-page="main.currentPage"
                    v-model:page-size="main.pageSize" :page-sizes="[100, 200, 300, 400]" :small="true"
                    layout="total, sizes, prev, pager, next, jumper" :total="main.Total" @size-change="handleSizeChange"
                    @current-change="handleCurrentChange" />
                </el-tab-pane>
              </el-tabs>
              <el-row>
                <el-col :span="15">
                  <!-- 工序信息 -->
                  <el-tabs v-model="tabfirst">
                    <el-tab-pane label="工序信息" name="first" style="width: 100%;">
                      <el-table border style="width: 100%" :data="specList" :height="270" ref="specTableRef"
                        @selection-change="selectSpecChange">
                        <el-table-column type="selection" width="40"></el-table-column>
                        <el-table-column prop="WORKFLOWSTEPNAME" label="工序" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="SPECTYPENAME" label="工序类型" width="80"></el-table-column>
                        <el-table-column prop="ISLASTSTEP" label="是否末序" width="80"></el-table-column>
                        <el-table-column prop="ISKEY" label="关键工序" width="90"></el-table-column>
                        <el-table-column prop="WORKCENTER" label="并行工序组" width="90"></el-table-column>
                        <el-table-column prop="TEAMNAME" label="责任班组" width="90"></el-table-column>
                        <el-table-column prop="STATUS" label="任务状态" width="80"></el-table-column>
                        <el-table-column prop="PLANNEDSTARTDATE" label="计划开始时间" width="110" :formatter="dateFormatter">
                        </el-table-column>
                        <el-table-column prop="PLANNEDFINISHDATE" label="计划结束时间" width="110" :formatter="dateFormatter">
                        </el-table-column>
                        <el-table-column prop="SENDSTATUS" label="配送提请状态" width="110"></el-table-column>
                      </el-table>
                    </el-tab-pane>
                  </el-tabs>
                </el-col>
                <!-- 工步信息 -->
                <el-col :span="9">
                  <el-tabs v-model="tabfirst1">
                    <el-tab-pane label="工步信息" name="first1" style="width: 100%;">
                      <el-table border style="width: 100%" :data="stepList" :height="270" ref="stepTableRef">
                        <el-table-column type="selection" width="40"></el-table-column>
                        <el-table-column prop="WORKFLOWSTEPNAME" label="工序" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="STEPINFONAME" label="工步" width="100" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="STEPNO" label="工步号" width="80"></el-table-column>
                        <el-table-column prop="WORKER" label="工人" width="100"></el-table-column>
                        <el-table-column prop="CHECKER" label="检验员" width="100"></el-table-column>
                      </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="排故单" name="first2" style="width: 100%;">
                      <el-table border style="width: 100%" :data="dealscrap.dealFaultBillList" :height="270">
                        <el-table-column prop="DEALFAULTBILLNAME" label="排故单号" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="PRODUCTFAMILYNAME" label="机型" width="100" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="MACHINE" label="发动机号" width="80" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="COMPRODUCTNAME" label="组合件号" width="100" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="MACHINEWORKHOURS" label="工作时间" width="100"></el-table-column>
                        <el-table-column prop="DEALFAULTTYPE" label="排故类型" width="80" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="TRANSFERSTATUS" label="返件状态" width="80" show-overflow-tooltip>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                    <el-tab-pane label="报废单" name="first3" style="width: 100%;">
                      <el-table border style="width: 100%" :data="dealscrap.scrapList" :height="270">
                        <el-table-column prop="FERTAUFNR" label="生产订单号" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="MATNR" label="零件号" width="100" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="ZPCH" label="批次号" width="120" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="EMPLOYEE" label="报废人" width="100" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="LOSSQTY" label="报废数" width="80"></el-table-column>
                        <el-table-column prop="CREATEDATE" label="报废时间" width="80" show-overflow-tooltip>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                  </el-tabs>
                </el-col>
              </el-row>
            </el-scrollbar>
          </div>
        </el-card>
        <!-- 按钮区域 -->
        <div class="handle-container">
          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleContainerSpecCheck(0)">
                <el-icon class="item-icon">
                  <Odometer />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">检验</div>
          </div>

          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleCheckQualified">
                <el-icon class="item-icon">
                  <Document />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">合格</div>
          </div>

          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleCheckUnqualified(1)">
                <el-icon class="item-icon">
                  <refresh-left />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">不合格审理申请</div>
          </div>
          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handlePupInputChechPoint">
                <el-icon class="item-icon">
                  <Edit />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">实测值录入</div>
          </div>

          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleDocumentViewClick">
                <el-icon class="item-icon">
                  <Document />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">工艺查看</div>
          </div>

          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleQualityProblemLook">
                <el-icon class="item-icon">
                  <zoom-in />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">质量问题查看</div>
          </div>

          <div class="item">
            <div class="item-image-container">
              <el-link :underline="false" @click="handleQualityDeal">
                <el-icon class="item-icon">
                  <Operation />
                </el-icon>
              </el-link>
            </div>
            <div class="item-text">质量问题处置</div>
          </div>
        </div>
      </el-col>
    </el-row>

    <!-- 文档查看对话框 -->
    <el-dialog v-model="documentViewDialogVisible" title="文档查看" width="60%" :draggable="true" align-center>
      <el-row :gutter="10">
        <el-col :span="14">
          <el-scrollbar height="400">
            <el-card>
              <template #header>
                <div style="display: flex;align-items: center;position: relative;">
                  <el-icon class="card-header-icon" style="font-size: 20px;">
                    <info-filled />
                  </el-icon>
                  <span class="card-header-text">工艺信息</span>
                </div>
              </template>
              <el-tree :data="treeData" node-key="id" :default-expand-all="true" :expand-on-click-node="false"
                @node-click="handleNodeClick">
                <template #default="scope">
                  <el-icon v-if="scope.data.type !== 'spec'" style="color:orange;margin-right: 10px;">
                    <Folder />
                  </el-icon>
                  <el-icon v-else style="margin-right: 10px;">
                    <Grid />
                  </el-icon>
                  {{scope.data.label}}
                </template>
              </el-tree>
            </el-card>
          </el-scrollbar>
        </el-col>
        <el-col :span="10">
          <el-card>
            <template #header>
              <div style="display: flex;align-items: center;position: relative;">
                <el-icon class="card-header-icon" style="font-size: 20px;">
                  <List />
                </el-icon>
                <span class="card-header-text">文档清单</span>
              </div>
            </template>
            <el-table :data="documentList" stripe border>
              <el-table-column type="index" width="50"></el-table-column>
              <el-table-column label="文档名称" prop="documentname" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="操作" prop="filepath" width="120">
                <template #default="scope">
                  <el-link type="primary" @click="handleOpenDocumentClick(scope.row.filepath)">查看文档</el-link>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
        </el-col>
      </el-row>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="documentViewDialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 检验、不合格审理申请对话框 -->
    <el-dialog v-model="unqualified.unqualifiedDialogVisible" :title="unqualified.type===1?'不合格审理申请':'检验合格/报废'"
      width="50%" :draggable="true" align-center>
      <el-scrollbar :height="inputHeight+125">
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="检验任务" name="first" style="width: 100%;">
            <el-table border style="width: 100%" :data="unqualified.checkList" :height="200"
              @row-click="selectcheckListRow" highlight-current-row>
              <el-table-column prop="WORKFLOWSTEPNAME" label="工序" show-overflow-tooltip></el-table-column>
              <el-table-column prop="STEPINFONAME" label="工步" show-overflow-tooltip></el-table-column>
              <el-table-column prop="WORKER" label="工人" width="130"></el-table-column>
              <el-table-column prop="CHECKER" label="检验员" width="100"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="配套件" name="first" style="width: 100%;">
            <el-row>
              <el-col :span="8">
                <el-table border style="width: 100%" :data="unqualified.bigsmallProductList" :height="200"
                  @row-click="selectbigsmallProductListRow" highlight-current-row>
                  <el-table-column prop="PRODUCTNAME" label="零件图号" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="PDESC" label="零件名称" width="130" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="QTYREQUIRED" label="需求数量" width="110"></el-table-column>
                </el-table>
              </el-col>
              <el-col :span="16">
                <el-table border style="width: 100%" :data="unqualified.bigsmallList" :height="200"
                  @row-click="selectunqualifiedbigsmallListRow" highlight-current-row>
                  <el-table-column prop="PRODUCTBATCHNO" label="零件批次号" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="ISSUEQTY" label="配套数量" width="100"></el-table-column>
                  <el-table-column prop="CONFIRMQTY" label="实装数量" width="100"></el-table-column>
                  <el-table-column prop="LOSSQTY" label="报废数量" width="100"></el-table-column>
                  <el-table-column prop="STATUS" label="创建周转状态" width="110"></el-table-column>
                  <el-table-column prop="DEALSTATUS" label="排故单" width="100"></el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <el-form :inline="true" :label-position="'top'" v-if="unqualified.type===0">
              <el-form-item label="报废数量">
                <el-input v-model="unqualified.ckeckForm.ScrapQty" style="width: 120px;" clearable></el-input>
              </el-form-item>
              <el-form-item label="报废原因">
                <el-select v-model="unqualified.ckeckForm.Reason" style="width: 120px;">
                  <el-option v-for="item in unqualified.lossReasonList" :label="item.LOSSREASONNAME"
                    :value="item.LOSSREASONID"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="备注">
                <el-input v-model="unqualified.ckeckForm.Note" type="textarea" style="width: 420px;"></el-input>
              </el-form-item>
            </el-form>
          </el-tab-pane>
        </el-tabs>

        <el-tabs v-model="tabfirst" v-if="unqualified.type===0">
          <el-tab-pane label="购代件报废" name="first" style="width: 100%;">
            <el-form :inline="true" :label-position="'top'">
              <el-form-item label="件号">
                <el-input v-model="unqualified.ReplaceBuy.ProductName" style="width: 140px;" placeholder="请输入查询条件"
                  clearable @clear="ClearProductInfo">
                  <template #append>
                    <el-button @click="SearchProductList" v-popover="popoverRef">
                      <el-icon>
                        <Search />
                      </el-icon>
                    </el-button>
                  </template>
                </el-input>
                <el-popover ref="popoverRef" trigger="click" title="" virtual-triggering persistent :width="200">
                  <el-menu style="border: none;">
                    <el-menu-item v-for="item in unqualified.productList" :value="item.PRODUCTID"
                      :label="item.PRODUCTNAME" :index="item.PRODUCTID" style="height: 30px;"
                      @click="selectProductInfo(item)">
                      <el-text class="mx-1" type="primary"> {{item.PRODUCTNAME}}{{item.DESCRIPTION}}</el-text>
                    </el-menu-item>
                  </el-menu>
                </el-popover>
              </el-form-item>
              <el-form-item label="批次号">
                <el-input v-model="unqualified.ReplaceBuy.BatchNo" style="width: 120px;" clearable></el-input>
              </el-form-item>
              <el-form-item label="报废数量">
                <el-input v-model="unqualified.ReplaceBuy.ScrapQty" style="width: 120px;" clearable></el-input>
              </el-form-item>
              <el-form-item label="报废原因">
                <el-select v-model="unqualified.ReplaceBuy.Reason" style="width: 120px;">
                  <el-option v-for="item in unqualified.lossReasonList" :label="item.LOSSREASONNAME"
                    :value="item.LOSSREASONID"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="备注">
                <el-input v-model="unqualified.ReplaceBuy.Note" type="textarea" style="width: 320px;"></el-input>
              </el-form-item>
            </el-form>

          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst" v-if="unqualified.type===1">
          <el-tab-pane label="不合格审理" name="first" style="width: 100%;">
            <el-form :inline="true" :label-position="'top'">
              <el-form-item label="生产订单号">
                <el-input v-model="unqualified.unqualifiedForm.mfgOrderName" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="型别">
                <el-input v-model="unqualified.unqualifiedForm.Type" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="工区">
                <el-input v-model="unqualified.unqualifiedForm.WorkCenter" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="批次号">
                <el-input v-model="unqualified.unqualifiedForm.BatchNum" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="物料号">
                <el-input v-model="unqualified.unqualifiedForm.MaterialNo" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="炉批号">
                <el-input v-model="unqualified.unqualifiedForm.StoveBatchNum" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="工序号">
                <el-input v-model="unqualified.unqualifiedForm.Spec" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="工序名称">
                <el-input v-model="unqualified.unqualifiedForm.SpecDesc" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="工步号">
                <el-input v-model="unqualified.unqualifiedForm.StepNo" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="工步名称">
                <el-input v-model="unqualified.unqualifiedForm.StepName" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="加工总数">
                <el-input v-model="unqualified.unqualifiedForm.TotalNum" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="不合格品数">
                <el-input v-model="unqualified.unqualifiedForm.UnqualifiedNum" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="审理单位">
                <el-select v-model="unqualified.unqualifiedForm.TrialUnit" style="width: 120px;">
                  <el-option v-for="item in unqualified.TrialUnitList" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="责任单位">
                <el-select v-model="unqualified.unqualifiedForm.DutyUnit" style="width: 120px;">
                  <el-option v-for="item in unqualified.DutyUnitList" :label="item.DutyUnitName"
                    :value="item.DutyUnitValue"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="零件类别">
                <el-select v-model="unqualified.unqualifiedForm.PartCategory" style="width: 120px;">
                  <el-option label="关键件" value="01"></el-option>
                  <el-option label="重要件" value="02"></el-option>
                  <el-option label="一般件" value="03"></el-option>
                  <el-option label="试验件" value="04"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="不合格类别">
                <el-select v-model="unqualified.unqualifiedForm.UnqualifiedCategory" style="width: 120px;">
                  <el-option label="0类" value="0"></el-option>
                  <el-option label="Ⅰ类" value="Ⅰ"></el-option>
                  <el-option label="Ⅱ类" value="Ⅱ"></el-option>
                  <el-option label="Ⅲ类" value="Ⅲ"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="材料牌号">
                <el-input v-model="unqualified.unqualifiedForm.MaterialBrandNum" style="width: 120px;"></el-input>
              </el-form-item>
              <el-form-item label="版次">
                <el-input v-model="unqualified.unqualifiedForm.VersionNo" style="width: 120px;"></el-input>
              </el-form-item>
            </el-form>

          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst" v-if="unqualified.type===1">
          <el-tab-pane label="缺陷信息" name="first" style="width: 100%;">
            <el-form :inline="true" :label-position="'top'">
              <el-form-item label="编码-代码组">
                <el-select v-model="unqualified.DefectsForm.CodeCodeGroups" style="width: 120px;" disabled>
                  <el-option value="LYD00002" label="LYD00002"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="编码-代码">
                <el-select v-model="unqualified.DefectsForm.EncodeCode" style="width: 120px;">
                  <el-option v-for="item in unqualified.EncodeCodeList" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="缺陷-代码组">
                <el-select v-model="unqualified.DefectsForm.DefectsCodeGroups" style="width: 120px;"
                  @change="selectDefectsCode">
                  <el-option label="" value=""></el-option>
                  <el-option v-for="item in unqualified.DefectsCodeGroupsList" :label="item.LOSSREASONGROUPNAME"
                    :value="item.LOSSREASONGROUPID"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="缺陷-代码">
                <el-select v-model="unqualified.DefectsForm.DefectsCode" style="width: 120px;"
                  @change="selectLossSequence">
                  <el-option label="" value=""></el-option>
                  <el-option v-for="item in unqualified.DefectsCodeList" :label="item.LOSSREASONNAME"
                    :value="item.LOSSREASONID"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="缺陷-排序号">
                <el-input v-model="unqualified.DefectsForm.DefectsOrderNo" style="width: 120px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="主题长文本（缺陷文本）">
                <el-input v-model="unqualified.DefectsForm.Defects" type="textarea" style="width: 280px;"></el-input>
              </el-form-item>
              <el-form-item label="缺陷短文本描述">
                <el-input v-model="unqualified.DefectsForm.DefectsShort" type="textarea" style="width: 280px;">
                </el-input>
              </el-form-item>
              <el-form-item label="行项目缺陷长文本">
                <el-input v-model="unqualified.DefectsForm.DefectsLong" type="textarea" style="width: 280px;">
                </el-input>
              </el-form-item>
            </el-form>

          </el-tab-pane>
        </el-tabs>
      </el-scrollbar>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="success" @click="saveCheckResultData" v-if="unqualified.type===0">提交</el-button>
          <el-button type="success" @click="saveUnqualifiedData" v-if="unqualified.type===1">提交</el-button>
          <el-button @click="unqualified.unqualifiedDialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 实测值对话框 -->
    <el-dialog v-model="checkPoint.checkPointDialogVisible" title="工序检测项实测值录入" width="60%" :draggable="true"
      align-center>
      <el-scrollbar :height="inputHeight+175">
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="批次信息" name="first" style="width: 100%;">
            <el-table border style="width: 100%" :data="checkPoint.containerList" :height="200"
              @row-click="selectContainer" highlight-current-row>
              <el-table-column prop="MfgorderName" label="生产订单" show-overflow-tooltip></el-table-column>
              <el-table-column prop="Machine" label="发动机号" width="110" show-overflow-tooltip></el-table-column>
              <el-table-column prop="TogetherFlag" label="任务单号" width="130" show-overflow-tooltip></el-table-column>
              <el-table-column prop="WorkFlowStepName" label="当前工序" width="100" show-overflow-tooltip></el-table-column>
              <el-table-column prop="ProductName" label="零件号" width="80"></el-table-column>
              <el-table-column prop="ProductRev" label="零件版本" width="80"></el-table-column>
              <el-table-column prop="ProductDescription" label="零件名称" show-overflow-tooltip></el-table-column>
              <el-table-column prop="ContainerType" label="批次类型" width="80"></el-table-column>
              <el-table-column prop="StepinfoName" label="工步"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="检测项信息" name="first" style="width: 100%;">
            <el-row>
              <el-col :span="16">
                <el-table border style="width: 100%" :data="checkPoint.checkPointList" :height="200"ref="checkPointTableRef"
                  @row-click="selectcheckPointRow" @selection-change="handleSelectionCheckPointChange" highlight-current-row>
                  <el-table-column type="selection"></el-table-column>
                  <el-table-column prop="NAME" label="关键特性标识" show-overflow-tooltip width="110"></el-table-column>
                  <el-table-column prop="CHECKPOINTNOTEDIS" label="检测项内容" width="110">
                    <template #default="scope">
                      <div v-html="scope.row.CHECKPOINTNOTEDIS"></div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="CHECKREQUIRE" label="规定值代号" width="100" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="KEYCHECKNAME" label="关键过程检" width="100" show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column prop="MEOPCHECKNAME" label="工序检" width="70" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="QUALITYCHECKNAME" label="质保单" width="70"></el-table-column>
                  <el-table-column prop="DRAWINGREQUIRE" label="图纸要求" width="80"></el-table-column>
                  <el-table-column prop="INPUTNUM" label="录入次数" width="80"></el-table-column>
                  <el-table-column prop="STATUS" label="录入状态" width="80">
                    <template #default="scope">
                      <el-tag :type="scope.row.STATUS==='未录'?'danger':''">
                        {{scope.row.STATUS}}
                      </el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column prop="CHECKSTATUS" label="检验状态">
                    <template #default="scope">
                      <el-tag :type="scope.row.CHECKSTATUS==='未录'?'danger':''">
                        {{scope.row.CHECKSTATUS}}
                      </el-tag>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
              <el-col :span="8">
                <el-table border style="width: 100%" :data="checkPoint.checkPointResultList" :height="200"
                  @row-click="selectcheckPointResultRow" highlight-current-row>
                  <el-table-column prop="WORKCHECKPOINTRESULTNOTE" label="工人实测值" width="100">
                    <template #default="scope">
                      <div v-html="scope.row.WORKCHECKPOINTRESULTNOTE"></div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="WORKER" label="工人" width="80"></el-table-column>
                  <el-table-column prop="CHECKPOINTRESULTNOTE" label="检验实测值" width="100">
                    <template #default="scope">
                      <div v-html="scope.row.CHECKPOINTRESULTNOTE"></div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="CHECKER" label="检验员" width="80"></el-table-column>
                  <el-table-column prop="NOTES" label="备注" show-overflow-tooltip></el-table-column>
                </el-table>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
        <el-row>
          <el-col :span="10">
            <iframe :src="checkPointUrl" style="border:none;width:100%;height:350px" id="pointContent"></iframe>
          </el-col>
          <el-col :span="14">
            <el-input v-model="checkPoint.Notes" type="textarea" label="备注" placeholder="检验备注信息录入"
              style="margin-top: 20px;height: 100px;"></el-input>
          </el-col>
        </el-row>
      </el-scrollbar>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="success" @click="saveCheckPointResult">保存</el-button>
          <el-button @click="checkPoint.checkPointDialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 质量问题查看对话框 -->
    <el-dialog v-model="qualityLook.qualityLookDialogVisible" title="质量问题查看" width="50%" :draggable="true" align-center>
      <el-scrollbar :height="inputHeight+125">
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="质量问题查看" name="first" style="width: 100%;">
            <el-table border style="width: 100%" :data="qualityLook.qualityLookList" :height="500"
              highlight-current-row>
              <el-table-column prop="PRODUCTNAME" label="部件号" width="130" show-overflow-tooltip></el-table-column>
              <el-table-column prop="CONTENT" label="内容" show-overflow-tooltip></el-table-column>
              <el-table-column prop="ENGINENO" label="发动机号" width="130" show-overflow-tooltip></el-table-column>
              <el-table-column prop="ISADD" label="是否新增" width="100" show-overflow-tooltip></el-table-column>
              <el-table-column prop="FULLNAME" label="创建人" width="120"></el-table-column>
              <el-table-column prop="CREATETIME" label="创建时间"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-scrollbar>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="qualityLook.qualityLookDialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 质量问题处置对话框 -->
    <el-dialog v-model="qualityDeal.qualityDealDialogVisible" title="质量问题处置" width="60%" :draggable="true" align-center>
      <el-scrollbar :height="inputHeight+130">
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="工序信息" name="first" style="width: 100%;">
            <el-descriptions class="margin-top" :column="5" :size="true" border>
              <el-descriptions-item label="任务单号">
                {{qualityDeal.containerspecInfo.TOGETHERFLAG}}
              </el-descriptions-item>
              <el-descriptions-item label="发动机号">
                {{qualityDeal.containerspecInfo.MACHINE}}
              </el-descriptions-item>
              <el-descriptions-item label="订单号">
                {{qualityDeal.containerspecInfo.MFGORDERNAME}}
              </el-descriptions-item>
              <el-descriptions-item label="件号名称">
                {{qualityDeal.containerspecInfo.DESCRIPTION}}
              </el-descriptions-item>
              <el-descriptions-item label="阶段">
                {{qualityDeal.containerspecInfo.STEPNAME}}
              </el-descriptions-item>
              <el-descriptions-item label="工序">
                {{qualityDeal.containerspecInfo.WORKFLOWSTEPNAME}}
              </el-descriptions-item>
              <el-descriptions-item label="开始计划时间">
                {{qualityDeal.containerspecInfo.PLANNEDSTARTDATE}}
              </el-descriptions-item>
              <el-descriptions-item label="开始完成时间">
                {{qualityDeal.containerspecInfo.PLANNEDCOMPLETIONDATE}}
              </el-descriptions-item>
              <el-descriptions-item label="装配工人">
                {{qualityDeal.containerspecInfo.WORKER}}
              </el-descriptions-item>
              <el-descriptions-item label="检验员">
                {{qualityDeal.containerspecInfo.CHECKER}}
              </el-descriptions-item>
            </el-descriptions>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="配套件信息" name="first" style="width: 100%;">
            <el-table border style="width: 100%" :data="qualityDeal.bigsmallList" :height="200"
              @row-click="selectbigsmallListRow" highlight-current-row>
              <el-table-column prop="PRODUCTNAME" label="零件图号" show-overflow-tooltip></el-table-column>
              <el-table-column prop="QTYREQUIRED" label="需求数量"></el-table-column>
              <el-table-column prop="PRODUCTBATCHNO" label="批次号"></el-table-column>
              <el-table-column prop="ISSUEQTY" label="配套数量" width="100"></el-table-column>
              <el-table-column prop="CONFIRMQTY" label="实装数量" width="100"></el-table-column>
              <el-table-column prop="LOSSQTY" label="报废数量" width="100"></el-table-column>
              <el-table-column prop="STATUS" label="创建周转状态" width="110"></el-table-column>
              <el-table-column prop="DEALSTATUS" label="排故单" width="100"></el-table-column>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="处置单信息" name="first" style="width: 100%;">
            <el-form :inline="true" :model="qualityDeal.formData" :label-position="'top'">
              <el-form-item label="零件图号">
                <el-input v-model="qualityDeal.formData.PRODUCTNAME" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="零件名称">
                <el-input v-model="qualityDeal.formData.PDESC" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="产品型号">
                <el-input v-model="qualityDeal.formData.ProductFamilyName" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="材料牌号">
                <el-input v-model="qualityDeal.formData.MaterialTrademark" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="流水卡（批次）号">
                <el-input v-model="qualityDeal.formData.PRODUCTBATCHNO" style="width: 140px;"></el-input>
              </el-form-item>
              <el-form-item label="总数/重量">
                <el-input v-model="qualityDeal.formData.QTYREQUIRED" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="不合格品数">
                <el-input v-model="qualityDeal.formData.UnqualifiedNum" style="width: 140px;" type="number" min="0"
                  clearable></el-input>
              </el-form-item>
              <el-form-item label="检验编号">
                <el-input v-model="qualityDeal.formData.CheckNO" style="width: 140px;" clearable></el-input>
              </el-form-item>
              <el-form-item label="零件类别">
                <el-select v-model="qualityDeal.formData.PartCategory" style="width: 140px;">
                  <el-option label="关键件" value="01"></el-option>
                  <el-option label="重要件" value="02"></el-option>
                  <el-option label="一般件" value="03"></el-option>
                  <el-option label="试验件" value="04"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="责任者">
                <el-select v-model="qualityDeal.formData.DUTYEMPLOYEEID" style="width: 140px;" filterable remote
                  :remote-method="GetEmployees" clearable>
                  <el-option v-for="item in qualityDeal.employeeList" :key="item.ID" :label="item.EMPLOYEENAME"
                    :value="item.ID" />
                </el-select>
              </el-form-item>
              <el-form-item label="图纸版次">
                <el-input v-model="qualityDeal.formData.Part_RevID" style="width: 140px;" disabled></el-input>
              </el-form-item>
              <el-form-item label="责任单位">
                <el-select v-model="qualityDeal.formData.FactoryID" style="width: 140px;" clearable>
                  <el-option v-for="item in qualityDeal.factoryList" :key="item.FACTORYID" :label="item.FACTORYNAME"
                    :value="item.FACTORYID" />
                </el-select>
              </el-form-item>
              <el-form-item label="问题性质">
                <el-select v-model="qualityDeal.formData.problemNature" style="width: 140px;" clearable>
                  <el-option label="重大" value="10"></el-option>
                  <el-option label="严重" value="20"></el-option>
                  <el-option label="一般A类外场" value="30"></el-option>
                  <el-option label="一般A类厂内" value="40"></el-option>
                  <el-option label="一般A类厂外" value="50"></el-option>
                </el-select>
              </el-form-item>
            </el-form>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-model="tabfirst">
          <el-tab-pane label="不合格情况" name="first" style="width: 100%;">
            <el-form :inline="false" :model="qualityDeal.formData" :label-position="'left'">
              <el-form-item label="不合格描述">
                <el-input v-model="qualityDeal.formData.UnqualifiedDescribe" type="textarea" style="width: 540px;"
                  clearable></el-input>
              </el-form-item>
              <el-form-item label="是否有关键特性超差">
                <el-radio-group v-model="qualityDeal.formData.IsKeyFeatures" class="ml-4">
                  <el-radio :value="1" size="small">是</el-radio>
                  <el-radio :value="0" size="small">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否有重要特性超差">
                <el-radio-group v-model="qualityDeal.formData.IsImportantFeatures" class="ml-4">
                  <el-radio :value="1" size="small">是</el-radio>
                  <el-radio :value="0" size="small">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否有设计基准要素超差">
                <el-radio-group v-model="qualityDeal.formData.IsDesignBasisFeatures" class="ml-4">
                  <el-radio :value="1" size="small">是</el-radio>
                  <el-radio :value="0" size="small">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-form>
          </el-tab-pane>
        </el-tabs>
      </el-scrollbar>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="success" @click="handleSavequalityDeal">确定</el-button>
          <el-button @click="qualityDeal.qualityDealDialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>

  </div>

  <script type="module">
    const { createApp, reactive, ref, toRef, toRefs, onMounted, watch, unref } = Vue
    const { ElMessage, ElLoading, ElMessageBox, ElNotification } = ElementPlus
    import { useFetch } from '../../../Scripts/hooks/useFetch.js';
    import { commonFetch } from '../../../Scripts/ZsJs/commonFetch.js';
    import { splitDate } from '../../../Scripts/utils/format.js';//时间截取
    import { usePageHeightSet } from '../../../Scripts/hooks/workreport/usePageHeightSet.js';//页面高度计算
    import { useGetUserInfo } from '../../../Scripts/hooks/useGetUserInfo.js';//获取账号信息
    import { getParams } from '../../../Scripts/utils/common.js';//获取页面参数
    import { useDocumentView } from '../../../Scripts/hooks/workreport/useDocumentView.js';//文档查看

    const App = {
      setup() {
        const baseAPI = '../../../Ashx/ContainerStepWorkReportVue3PageHandler.ashx';
        const ZSbaseAPI = '../../../Ashx/ZSHandler/ZSContainerStepWorkReportHandler.ashx';
        const FetchCommonUrl = '../../../Ashx/FetchCommonHandler.ashx';
        const ZSCheckUrl = '../../../Ashx/ZsHandler/ZSContainerCheckInfoManageHandler.ashx'//装配检验作业
        const ZSProductSearchUrl = '../../../Ashx/ZsHandler/ZSSendRequestHandler.ashx'//件号信息查询URL
        const checkPointUrl = `http://${window.location.hostname}/InSiteWebApplication/forms/Custom/htmlPage/StepCheckPoint/CheckPointSymbolInput.aspx`

        let currentTime = ref('');// 当前时间

        // 页面布局高度配置
        const { clientHeight, inputHeight, tableHeight } = usePageHeightSet();
        const { userInfo, getUserInfo } = useGetUserInfo();

        let tabfirst = ref('first');// 选项卡当前选中索引
        let tabfirst1 = ref('first1')

        const formData = reactive({
          ContainerNo: '',
          Machine: '',
          ProductName: '',
          TaskType: '',
        });
        const currentContainerRow = ref(null);
        const containerTableRef = ref(null)
        const specTableRef = ref(null)
        const stepTableRef = ref(null)
        const containerList = ref([]);
        const specList = ref([]);
        const stepList = ref([])
        const dealscrap = reactive({
          dealFaultBillList: [],
          scrapList: []
        });
        const main = reactive({
          currentPage: 1,
          pageSize: 20,
          Total: 0,
        });

        const worktimeInfo = reactive({ txtTimeAttribute: '0', txtSumWorkTime: '0', txtSumJX: '0' })//工时信息
        let currentSelectContainer = {}; // 任务单信息单选的批次
        //检验、不合格审理
        const checkFormm = reactive({ ScrapQty: '', Reason: '', Note: '' })
        const ReplaceBuyForm = reactive({ ProductID: '', ProductName: '', BatchNo: '', ScrapQty: '', Reason: '', Note: '' })
        const popoverRef = ref(null)

        const unqualified = reactive({
          unqualifiedDialogVisible: false,
          type: 0,
          checkListRow: null,
          bigsmallListRow: null,
          bigsmallProductListRow: null,
          checkList: [],//检验任务
          bigsmallProductList: [],//配套件零件
          bigsmallList: [],//配套件需求量
          lossReasonList: [],
          productList: [],
          ckeckForm: Object.assign({}, checkFormm),
          ReplaceBuy: Object.assign({}, ReplaceBuyForm),//购代件
          unqualifiedForm: {
            UnqualifiedCategory: '0', PartCategory: '01', TrialUnit: '600', mfgOrderName: '', Type: '', WorkCenter: '', BatchNum: '', MaterialNo: '', StoveBatchNum: '', Spec: '', SpecDesc: '', StepNo: '', StepName: '', TotalNum: '', UnqualifiedNum: '', DutyUnit: '', MaterialBrandNum: '', VersionNo: ''
          },//不合格审理
          DutyUnitList: [],//责任单位List
          DefectsCodeGroupsList: [],//缺陷代码组List
          DefectsCodeList: [],//缺陷代码List
          DefectsForm: { CodeCodeGroups: 'LYD00002', EncodeCode: 'D010', DefectsCodeGroups: '', DefectsCode: '', DefectsOrderNo: '', Defects: '', DefectsShort: '', DefectsLong: '' },
          TrialUnitList: [{ label: '盘轴厂', value: '600' }, { label: '机匣厂', value: '601' }, { label: '热表厂', value: '602' }, { label: '装配试车厂', value: '603' }, { label: '钣焊厂', value: '607' }, { label: '叶片厂', value: '608' }, { label: '结构件厂', value: '609' }],
          EncodeCodeList: [
            { label: '600-盘轴厂', value: 'D010' }, { label: '601-机匣厂', value: 'D020' }, { label: '602-热表厂', value: 'D030' }, { label: '603-装配试车厂', value: 'D040' }, { label: '607-钣焊厂', value: 'D050' }, { label: '608-叶片厂', value: 'D060' }, { label: '609-结构件厂', value: 'D070' },]
        });

        // 文档查看
        const {
          documentViewDialogVisible,
          treeData,//文档查看Tree数据
          documentList,//文档查看文件清单
          getDocumentViewTreeData,
          getDocumentList,
          downloadFile,
        } = useDocumentView();

        //实测值录入
        const checkPoint = reactive({
          checkPointDialogVisible: false,
          Notes: null,
          containerList: [],
          checkPointList: [],
          checkPointResultList: [],
          currentcContainer: null,
          currentcheckPointRow: null,
          currentcheckPointResultRow: null,
          currentcheckPointRows:[]
        });
        //质量问题查看
        const qualityLook = reactive({
          qualityLookDialogVisible: false,
          qualityLookList: [],
        })

        //质量问题处置
        const qualityDeal = reactive({
          qualityDealDialogVisible: false,
          containerspecInfo: {},
          bigsmallList: [],
          formData: {},
          employeeList: [],
          factoryList: []
        })
        //左侧扫卡结果对象
        const containerSearchScan = reactive({
          notReportedList: [],//【待报工】数据
          unReportDataRows: 0,//【待报工】总数
          unCheckContainerData: [],//【待检验】数据
          unCheckContainerCount: 0,//【待检验】总数
        })

        // 刷新员工信息数据
        async function handleUserInfoFlushClick() {
          await getWorkTime();
        }
        // 2.查询工时------------------------------
        async function getWorkTime() {
          const config = {
            url: `${ZSbaseAPI}?action=getWorkTime`,
          };
          const { tdata, rdata } = await commonFetch(config);
          worktimeInfo.txtTimeAttribute = rdata.value.txtTimeAttribute
          worktimeInfo.txtSumWorkTime = rdata.value.txtSumWorkTime
          worktimeInfo.txtSumJX = rdata.value.txtSumJX
        }

        // 扫卡事件
        let searchObj = reactive({ containername: '' });
        async function handleContainerSearchBlur(type) {
          if (searchObj.containername || type === 1) {
            const config = {
              url: `${ZSCheckUrl}?action=getScanContainerData&searchText=${searchObj.containername}`
            };
            const { tdata, rdata } = await commonFetch(config);
            if (tdata.value != null) {
              containerSearchScan.notReportedList = tdata
              containerSearchScan.unReportDataRows = tdata.value.length
            } else {
              containerSearchScan.notReportedList = []
              containerSearchScan.unReportDataRows = 0
            }
            if (rdata.value != null) {
              containerSearchScan.unCheckContainerData = rdata
              containerSearchScan.unCheckContainerCount = rdata.value.length
            } else {
              containerSearchScan.unCheckContainerData = []
              containerSearchScan.unCheckContainerCount = 0
            }
          }
        }
        async function selectContainerMenu(val) {
          formData.ContainerNo = val.index
          await queryContainerCheckData()
        }
        //查询待检验任务单数据---------------------------
        async function queryContainerCheckData() {
          const requestData = Object.assign({}, formData, main, { PartType: '' });
          const config = {
            url: `${ZSCheckUrl}?action=GetNotCheckContainer&data=${JSON.stringify(requestData)}`,
          };

          const { tdata, total } = await commonFetch(config);
          containerList.value = tdata.value === null ? [] : Array.from(tdata.value);
          main.Total = Number(total.value)
          specList.value = [];
          currentSelectContainer = {}
        }
        async function handleSizeChange(pageSize) {
          main.pageSize = pageSize
          await queryContainerCheckData()
        }
        async function handleCurrentChange(currentPage) {
          main.currentPage = currentPage
          await queryContainerCheckData()
        }
        //查询工序信息---------------------------------
        async function selectContainerRow(row, column, event) {
          const config = {
            url: `${ZSCheckUrl}?action=GetWorkflowStep&data=${JSON.stringify({ ContainerId: row.CONTAINERID, WorkflowId: row.WORKFLOWID })}`,
          };
          const { tdata } = await commonFetch(config);
          specList.value = tdata.value === null ? [] : Array.from(tdata.value);
          currentContainerRow.value = row//.CONTAINERID
          currentSelectContainer = { productid: row.PRODUCTID, workflowid: row.WORKFLOWID }
          specTableRef.value.toggleAllSelection();//默认全选
        }
        //查询工步信息-----------------------------------
        async function selectSpecChange(val) {
          if (val.length === 0) { stepList.value = []; return; }
          let specIDs = [];
          val.map(item => {
            specIDs.push(`'${item.WORKFLOWSTEPID}'`);
          });
          var formData = new FormData();
          formData.append("WorkflowstepId", specIDs.join(','));
          formData.append("ContainerID", currentContainerRow.value.CONTAINERID);
          formData.append("WorkflowId", currentContainerRow.value.WORKFLOWID);
          const config = {
            url: `${ZSCheckUrl}?action=GetZSWorkFlowStepAndStepInfo`,
            data: formData
          };
          const { tdata } = await commonFetch(config);
          stepList.value = tdata.value === null ? [] : Array.from(tdata.value);
          stepTableRef.value.toggleAllSelection();//默认全选
          await getDealFaultBillAndScrap();
        }
        // 查询排故单、报废单信息
        async function getDealFaultBillAndScrap() {
          const config = {
            url: `${ZSCheckUrl}?action=GetDealFaultBillAndScrap&data=${JSON.stringify({ TogetherFlag: currentContainerRow.value.TOGETHERFLAG })}`,
          };
          const { tdata, rdata } = await commonFetch(config);
          dealscrap.dealFaultBillList = tdata
          dealscrap.scrapList = rdata
        }
        //重置
        async function qureyReset() {
          formData.ContainerNo = '',
            formData.Machine = '',
            formData.ProductName = '',
            formData.TaskType = '',
            await queryContainerCheckData()
        }

        // 日期字符串截取
        function dateFormatter(row, column, cellValue, index) {
          return cellValue && cellValue.includes('T') ? cellValue.split('T')[0] : cellValue;
        }

        //1.【检验】按钮点击
        async function handleContainerSpecCheck(type) {
          let mrow = currentContainerRow.value;
          let wsrows = specTableRef.value.getSelectionRows();
          let steprows = stepTableRef.value.getSelectionRows();
          if (steprows.length === 0) {
            return ElMessage.error('请勾选工步再进行操作');
          }
          unqualified.checkList = steprows
          const config = {
            url: `${ZSCheckUrl}?action=GetLossReason`,
          };
          const { tdata } = await commonFetch(config);
          unqualified.lossReasonList = tdata
          unqualified.bigsmallProductList = []
          unqualified.bigsmallList = []
          unqualified.bigsmallListRow = null
          unqualified.bigsmallProductListRow = null
          unqualified.ckeckForm = Object.assign({}, checkFormm)
          unqualified.ReplaceBuy = Object.assign({}, ReplaceBuyForm)
          if (tdata.value !== null) {
            unqualified.ckeckForm.Reason = tdata.value[0].LOSSREASONID
            unqualified.ReplaceBuy.Reason = tdata.value[0].LOSSREASONID
          }
          unqualified.unqualifiedDialogVisible = true
          unqualified.type = type

        }
        //1.1【检验】---提交按钮点击
        async function saveCheckResultData() {
          console.info(unqualified.ckeckForm)
          console.info(unqualified.ReplaceBuy)
          let formData = new FormData()
          if (unqualified.checkListRow === null) {
            return ElMessage.error('请选择要进行操作的工序工步');
          }
          formData.append("mdata", JSON.stringify(unqualified.checkListRow))
          if (unqualified.ckeckForm.ScrapQty !== '' && unqualified.bigsmallListRow === null) {
            return ElMessage.error('存在报废数，请选择需要报废的配套信息');
          }
          if (unqualified.ckeckForm.ScrapQty !== '') {
            if (!/^[+-]?\d+$/.test(unqualified.ckeckForm.ScrapQty)) {
              return ElMessage.error('报废数量应为整数');
            }
            if (Number(unqualified.ckeckForm.ScrapQty) < 1) {
              return ElMessage.error('报废数量应大于0');
            }
            if (Number(unqualified.ckeckForm.ScrapQty) > Number(unqualified.bigsmallListRow.ISSUEQTY)) {
              return ElMessage.error('报废数量不能大于装配数量');
            }
            unqualified.ckeckForm.CollectErpMaterialID = unqualified.bigsmallListRow.COLLECTERPMATERIALID
            unqualified.ckeckForm.IssueErpMaterialID = unqualified.bigsmallListRow.ISSUEERPMATERIALID
          }
          formData.append("data", JSON.stringify(unqualified.ckeckForm))
          //购代件报废
          if (unqualified.ReplaceBuy.ProductID !== '' || unqualified.ReplaceBuy.BatchNo !== '') {
            if (unqualified.ReplaceBuy.ProductID === '') {
              return ElMessage.error('有购代件报废请选择产品');
            }
            if (unqualified.ReplaceBuy.ScrapQty === '') {
              return ElMessage.error('请输入报废数');
            }
            if (unqualified.ReplaceBuy.BatchNo === '') {
              return ElMessage.error('请输入批次号');
            }
          }
          if (unqualified.ReplaceBuy.ScrapQty !== '') {
            if (!/^[+-]?\d+$/.test(unqualified.ReplaceBuy.ScrapQty)) {
              return ElMessage.error('购代件报废数量应为整数');
            }
            if (Number(unqualified.ReplaceBuy.ScrapQty) < 1) {
              return ElMessage.error('购代件报废数量应大于0');
            }
            if (unqualified.ReplaceBuy.ProductID === '') {
              return ElMessage.error('有购代件报废请选择产品');
            }
            if (unqualified.ReplaceBuy.BatchNo === '') {
              return ElMessage.error('请输入批次号');
            }
          }
          unqualified.ReplaceBuy.mfgordername = currentContainerRow.value.MFGORDERNAME
          unqualified.ReplaceBuy.CONTAINERNO = currentContainerRow.value.TOGETHERFLAG
          formData.append("ddata", JSON.stringify(unqualified.ReplaceBuy))
          if (unqualified.ReplaceBuy.ScrapQty === '' && unqualified.ckeckForm.ScrapQty === '') {
            return ElMessage.error('请输入报废信息');
          }
          const config = {
            url: `${ZSCheckUrl}?action=SaveCheckResultData`,
            data: formData
          };
          const { Message, Result } = await commonFetch(config);
          if (Result) {
            ElMessage.success(Message)
            unqualified.ckeckForm = Object.assign(unqualified.ckeckForm, { ScrapQty: '', Note: '' })
            unqualified.ReplaceBuy = Object.assign(unqualified.ReplaceBuy, { ProductID: '', ProductName: '', BatchNo: '', ScrapQty: '', Note: '' })
            await selectbigsmallProductListRow(unqualified.bigsmallProductListRow)
          }
        }
        //2.【合格】按钮方法
        async function handleCheckQualified() {
          unqualified.bigsmallList = []
          unqualified.bigsmallProductList = []
          let mrow = currentContainerRow.value;
          let wsrows = specTableRef.value.getSelectionRows();
          let steprows = stepTableRef.value.getSelectionRows();
          if (mrow == null) {
            return ElMessage.error('请选择任务单再进行操作');
          }
          if (steprows.length === 0) {
            return ElMessage.error('请勾选工步再进行操作');
          }
          let formData = new FormData();
          formData.append("data", JSON.stringify({ productname: mrow.PRODUCTNAME, workflowid: mrow.WORKFLOWID }))
          formData.append("sdata", JSON.stringify(steprows))
          const config = {
            url: `${ZSCheckUrl}?action=CheckQualified`,
            data: formData
          };
          const { Message, Result } = await commonFetch(config);
          if (Result) {
            ElMessage.success(Message)
            await selectSpecChange(wsrows)
          }
        }


        //3.【不合格审理申请】按钮点击
        async function handleCheckUnqualified(type) {
          let mrow = currentContainerRow.value;
          let wsrows = specTableRef.value.getSelectionRows();
          let steprows = stepTableRef.value.getSelectionRows();
          if (steprows.length === 0) {
            return ElMessage.error('请勾选工步再进行操作');
          }
          unqualified.checkList = steprows
          unqualified.bigsmallProductList = []
          unqualified.bigsmallList = []
          unqualified.bigsmallListRow = null
          unqualified.bigsmallProductListRow = null

          const config = {
            url: `${ZSCheckUrl}?action=InitUnqualified`,
          };
          const { tdata, rdata } = await commonFetch(config);
          unqualified.DefectsCodeGroupsList = tdata
          unqualified.DutyUnitList = rdata
          unqualified.unqualifiedDialogVisible = true
          unqualified.type = type
          unqualified.unqualifiedForm = Object.assign(unqualified.unqualifiedForm, { UnqualifiedCategory: '0', PartCategory: '01', TrialUnit: '600' })
          unqualified.DefectsForm = Object.assign(unqualified.DefectsForm, { CodeCodeGroups: 'LYD00002', EncodeCode: 'D010' })
          if (rdata.value !== null) {
            unqualified.unqualifiedForm.DutyUnit = rdata.value[0].DutyUnitValue
          }
          unqualified.unqualifiedForm.mfgOrderName = mrow.MFGORDERNAME
          unqualified.unqualifiedForm.Type = mrow.PRODUCTFAMILYNAME
          unqualified.unqualifiedForm.WorkCenter = userInfo.value.workcentername

        }
        //
        async function selectDefectsCode(val) {
          const config = {
            url: `${ZSCheckUrl}?action=GetLossReasonByGroupID&lossreasongroupid=${val}`,
          };
          const { tdata } = await commonFetch(config);
          unqualified.DefectsCodeList = tdata
        }
        async function selectLossSequence(val) {
          const config = {
            url: `${ZSCheckUrl}?action=FillLossSequenceAndTxtData&lossreasongroupid=${unqualified.DefectsForm.DefectsCodeGroups}&lossreasonid=${val}`,
          };
          const { rdata } = await commonFetch(config);
          unqualified.DefectsForm.DefectsOrderNo = rdata.value.SEQUENCE
          unqualified.DefectsForm.DefectsShort = rdata.value.DESCRIPTION
        }
        //3.1【不合格审理申请】--提交按钮点击---------------------------------------------------------
        async function saveUnqualifiedData() {
          if (unqualified.checkListRow === null) {
            return ElMessage.error('没有选择对应的工步工序记录');
          }
          let Defects = unqualified.DefectsForm
          let unqualifiedd = unqualified.unqualifiedForm
          if (Defects.DefectsCodeGroups === '' || Defects.DefectsCode === '') {
            return ElMessage.error('请选择缺陷-代码组、缺陷-代码');
          }
          if (unqualifiedd.TotalNum === '' || unqualifiedd.TotalNum === null) {
            return ElMessage.error('加工总数不能为空');
          }
          if (!/^[+-]?\d+$/.test(unqualifiedd.TotalNum)) {
            return ElMessage.error('加工总数应为数字');
          }
          if (unqualifiedd.UnqualifiedNum === '') {
            return ElMessage.error('不合格品数不能为空');
          }
          if (Number(unqualifiedd.UnqualifiedNum) > Number(unqualifiedd.TotalNum)) {
            return ElMessage.error('不合格品数不能大于总待检数');
          }

          Defects.ContainerID = unqualified.checkListRow.CONTAINERID
          Defects.WorkflowStepID = unqualified.checkListRow.WORKFLOWSTEPID
          Defects.StepInfoID = unqualified.checkListRow.STEPINFOID
          unqualified.DefectsCodeGroupsList.map(item => {
            if (item.LOSSREASONGROUPID === Defects.DefectsCodeGroups) {
              Defects.DefectsCodeGroups = item.LOSSREASONGROUPNAME
            }
          })
          unqualified.DefectsCodeList.map(item => {
            if (item.LOSSREASONID === Defects.DefectsCode) {
              Defects.DefectsCode = item.LOSSREASONNAME
            }
          })

          let formData = new FormData();
          formData.append("ddata", JSON.stringify(Defects))
          formData.append("udata", JSON.stringify(unqualifiedd))
          const config = {
            url: `${ZSCheckUrl}?action=InsertUnqualifiedData`,
            data: formData
          };
          const { Message, Result } = await commonFetch(config);
          if (Result) {
            ElMessage.success(Message)
            unqualified.unqualifiedForm = Object.assign(unqualified.unqualifiedForm, { UnqualifiedCategory: '0', PartCategory: '01', TrialUnit: '600', BatchNum: '', MaterialNo: '', StoveBatchNum: '', Spec: '', SpecDesc: '', StepNo: '', StepName: '', TotalNum: '', UnqualifiedNum: '', DutyUnit: '', MaterialBrandNum: '', VersionNo: '' })
            unqualified.DefectsForm = { CodeCodeGroups: 'LYD00002', EncodeCode: 'D010', DefectsCodeGroups: '', DefectsCode: '', DefectsOrderNo: '', Defects: '', DefectsShort: '', DefectsLong: '' }
          }

        }

        async function selectcheckListRow(row) {
          unqualified.checkListRow = row//检验任务--单选的行
          let formData = new FormData();
          formData.append("data", JSON.stringify(row))
          const config = {
            url: `${ZSCheckUrl}?action=GetProductCollectInfo`,
            data: formData
          };
          const { tdata } = await commonFetch(config);
          unqualified.bigsmallProductList = tdata
          if (unqualified.type === 1) {
            unqualified.unqualifiedForm.TotalNum = row.QTY
            unqualified.unqualifiedForm.Spec = row.SPECNO
            unqualified.unqualifiedForm.SpecDesc = row.WORKFLOWSTEPNAME
            unqualified.unqualifiedForm.StepNo = row.STEPNO
            unqualified.unqualifiedForm.StepName = row.STEPINFONAME
          }
        }

        async function selectbigsmallProductListRow(row) {
          unqualified.bigsmallProductListRow = row
          let mrow = currentContainerRow.value;
          let formData = new FormData();
          formData.append("data", JSON.stringify({ type: "0", ContainerID: mrow.CONTAINERID, ProductName: row.PRODUCTNAME, ProductID: row.PRODUCTID, Machine: mrow.MACHINE }))
          const config = {
            url: `${ZSCheckUrl}?action=GetIssueMarterialInfo`,
            data: formData
          };
          const { tdata } = await commonFetch(config);
          unqualified.bigsmallList = tdata
          unqualified.unqualifiedForm.MaterialNo = row.PRODUCTNAME
        }
        async function selectunqualifiedbigsmallListRow(row) {
          unqualified.bigsmallListRow = row
          unqualified.unqualifiedForm.BatchNum = row.PRODUCTBATCHNO
        }
        //件号查询
        async function SearchProductList() {
          if (unqualified.ReplaceBuy.ProductName === '') {
            return //ElMessage.error('请输入查询条件');
          }
          const config = {
            url: `${ZSProductSearchUrl}?action=GetAllProduct&name=${unqualified.ReplaceBuy.ProductName}`,
          };
          const { tdata, Result } = await commonFetch(config);
          unqualified.productList = tdata
        }
        //件号查询选择
        async function selectProductInfo(item) {
          unqualified.ReplaceBuy.ProductName = item.PRODUCTNAME
          unqualified.ReplaceBuy.ProductID = item.ID
          popoverRef.value.hide()
        }
        //件号清除
        async function ClearProductInfo() {
          unqualified.ReplaceBuy.ProductID = ''
        }


        // 5.【工艺查看】按钮方法
        async function handleDocumentViewClick() {
          getDocumentViewTreeData({ currentSelectContainer, baseAPI });
        }

        // 5-1.【工艺查看】- 文档查看节点点击，查询工艺下的文档信息
        async function handleNodeClick(node) {
          const { id, type } = node;
          await getDocumentList({ url: `${baseAPI}`, method: 'getDocumentList', id, nodeType: type });
        }

        // 5-2.【工艺查看】- 打开文档
        async function handleOpenDocumentClick(filepath) {
          await downloadFile({ url: `${baseAPI}`, method: 'getDownloadUrl', filepath });
        }

        //4.【实测值录入】
        const checkPointTableRef=ref(null)
        async function handlePupInputChechPoint() {
          let mrow = currentContainerRow.value;
          let wsrows = specTableRef.value.getSelectionRows();
          let steprows = stepTableRef.value.getSelectionRows();
          if (wsrows.length === 0) {
            return ElMessage.error('请勾选工序再进行操作');
          }
          checkPoint.checkPointDialogVisible = true
          const formData = new FormData();
          formData.append('mdata', JSON.stringify({ ContainerID: mrow.CONTAINERID, ContainerName: mrow.CONTAINERNAME, Machine: mrow.MACHINE }));
          formData.append('data', JSON.stringify(steprows));
          const config = {
            url: `${ZSbaseAPI}?action=pupInputChechPoint`,
            data: formData
          };
          const { tdata } = await commonFetch(config);
          checkPoint.containerList = tdata
          checkPoint.checkPointList = []
          checkPoint.checkPointResultList = []
        }
        //4.1【实测值录入】---批次工序选择
        async function selectContainer(row, column, event) {
          const formData = new FormData();
          formData.append('data', JSON.stringify({ ContainerID: row.ContainerId, ProductID: row.ProductId, StepID: row.WorkFlowStepId, StepinfoID: row.StepinfoId }));
          const config = {
            url: `${ZSbaseAPI}?action=getStepCheckPointList`,
            data: formData
          };
          const { tdata, rdata } = await commonFetch(config);
          checkPoint.checkPointList = tdata
          checkPoint.currentcContainer = row
          checkPoint.checkPointResultList = []
        }
        //4.2【实测值录入】---检测项选择查询检测结果
        async function selectcheckPointRow(row, column, event) {
          checkPoint.currentcheckPointRow = row
          checkPointTableRef.value.clearSelection();//取消多选
          checkPoint.currentcheckPointRows=[];
          const formData = new FormData();
          formData.append('data', JSON.stringify({ ContainerID: checkPoint.currentcContainer.ContainerId, ProductID: checkPoint.currentcContainer.ProductId, StepID: checkPoint.currentcContainer.WorkFlowStepId, StepCheckPointID: row.STEPCHECKPOINTID }));
          const config = {
            url: `${ZSbaseAPI}?action=getStepCheckPointResultList`,
            data: formData
          };
          const { tdata, rdata } = await commonFetch(config);
          checkPoint.checkPointResultList = rdata
        }
        //4.2【实测值录入】---检测结果行点击
        async function selectcheckPointResultRow(row, column, event) {
          checkPoint.currentcheckPointResultRow = row

        }
        //4.3 【实测值录入】---保存
        async function saveCheckPointResult() {
          if (checkPoint.currentcheckPointRow === null&&checkPoint.currentcheckPointRows.length===0) {
            return ElMessage.error('请选择检测项再进行操作');
          }
          var strCode = document.getElementById("pointContent").contentDocument.getElementById("wucToleranceInput1_ftbFinalHtml_designEditor").contentDocument.body.innerHTML;
          if (strCode == "") {
            return ElMessage.error('实测值录入不能为空');
          }
          if(checkPoint.currentcheckPointRow !== null){
            if (Number(checkPoint.currentcheckPointRow.INPUTNUM) > checkPoint.checkPointResultList.length) {
              checkPoint.checkPointResultList.push({ CHECKPOINTRESULTNOTE: strCode, CHECKER: userInfo.value.employeename, STEPCHECKPOINTRESULTID: checkPoint.checkPointResultList.length, NOTES: checkPoint.Notes,INPUTNUM:checkPoint.currentcheckPointRow.INPUTNUM,StepCheckPointID:checkPoint.currentcheckPointRow.STEPCHECKPOINTID })
            } else {
              if (checkPoint.checkPointResultList.length > 0 && checkPoint.currentcheckPointResultRow === null) {
                return ElMessage.error('请选择已录入检测项结果再进行操作');
              } else {
                checkPoint.checkPointResultList.map(item => {
                  if (item.STEPCHECKPOINTRESULTID === checkPoint.currentcheckPointResultRow.STEPCHECKPOINTRESULTID) {
                    item.CHECKPOINTRESULTNOTE = strCode
                    item.NOTES = checkPoint.Notes
                  }
                });
              }
            }
          }else{
            checkPoint.currentcheckPointRows.forEach((item,index)=>{
              if (Number(item.INPUTNUM) > item.CINPUTNUM) {
                checkPoint.checkPointResultList.push({ CHECKPOINTRESULTNOTE: strCode, CHECKER: userInfo.value.employeename, STEPCHECKPOINTRESULTID: item.CINPUTNUM, NOTES: checkPoint.Notes,INPUTNUM:item.INPUTNUM,StepCheckPointID:item.STEPCHECKPOINTID  })
              }else{
                checkPoint.checkPointResultList.map(itemm => {
                  if (itemm.STEPCHECKPOINTID === item.STEPCHECKPOINTID) {
                    itemm.CHECKPOINTRESULTNOTE = strCode
                    itemm.NOTES = checkPoint.Notes
                  }
                });
              }
            });
          }
          let formData = new FormData();
          formData.append("ContainerID", currentContainerRow.value.CONTAINERID)
          //formData.append("StepCheckPointID", checkPoint.currentcheckPointRow.STEPCHECKPOINTID)
          //formData.append("INPUTNUM", checkPoint.currentcheckPointRow.INPUTNUM)
          formData.append("data", JSON.stringify(checkPoint.checkPointResultList))
          const config = {
            url: `${ZSbaseAPI}?action=saveCheckPointResult`,
            data: formData
          };
          const { Message, Result } = await commonFetch(config);
          if (Result) {
            ElMessage.success(Message)
            document.getElementById("pointContent").contentDocument.getElementById("wucToleranceInput1_ftbFinalHtml_designEditor").contentDocument.body.innerHTML = ""
            checkPoint.Notes = null
            if(checkPoint.currentcheckPointRow !== null){
              await selectcheckPointRow(checkPoint.currentcheckPointRow, null, null)
            }else{
               await  handleSelectionCheckPointChange(checkPoint.currentcheckPointRows);
            }
          }
        }
          //4.4【实测值录入】---检测项多选查询检测结果
          async function handleSelectionCheckPointChange(rows){
          checkPoint.currentcheckPointRows=rows;
          if(rows.length>0){
            checkPointTableRef.value.setCurrentRow();//取消单选
            checkPoint.currentcheckPointRow=null;
          }
          const STEPCHECKPOINTIDs=rows.map(item=>item.STEPCHECKPOINTID).join(',');
          const formData = new FormData();
          formData.append('data', JSON.stringify({ ContainerID: checkPoint.currentcContainer.ContainerId, ProductID: checkPoint.currentcContainer.ProductId, StepID: checkPoint.currentcContainer.WorkFlowStepId, StepCheckPointID: STEPCHECKPOINTIDs }));
          const config = {
            url: `${ZSbaseAPI}?action=getStepCheckPointResultList`,
            data: formData
          };
          const { tdata, rdata } = await commonFetch(config);
          checkPoint.checkPointResultList = rdata
          checkPoint.checkPointList.map(item=>{
             const exist=checkPoint.checkPointResultList.some(itemm=>itemm.STEPCHECKPOINTID===item.STEPCHECKPOINTID)
             if(exist){item.CHECKSTATUS="已录";}
          })
        }

        //6.【质量问题查看】
        async function handleQualityProblemLook() {
          let mrow = currentContainerRow.value;
          if (mrow === null) {
            return ElMessage.error('请选择任务单再进行操作');
          }
          qualityLook.qualityLookDialogVisible = true;
          const config = {
            url: `${ZSbaseAPI}?action=getQualityHistoryRecord&data=${JSON.stringify({ productname: mrow.MACHINENAME })}`,
          };
          const { tdata } = await commonFetch(config);
          qualityLook.qualityLookList = tdata
        }
        //7.【质量问题处置】
        async function handleQualityDeal() {
          let mrow = currentContainerRow.value;
          let wsrows = specTableRef.value.getSelectionRows();
          if (wsrows.length !== 1) {
            return ElMessage.error('请勾选一条工序再进行操作');
          }
          qualityDeal.bigsmallList = []
          qualityDeal.formData = { PartCategory: '01', problemNature: '50', IsKeyFeatures: 0, IsImportantFeatures: 0, IsDesignBasisFeatures: 0 }
          let workers = [];
          let checker = [];
          stepList.value.map(item => {
            if (!workers.includes(item.WORKER)) {
              workers.push(item.WORKER)
            }
            if (!checker.includes(item.CHECKER)) {
              checker.push(item.CHECKER)
            }
          });
          qualityDeal.containerspecInfo = mrow
          qualityDeal.containerspecInfo.WORKFLOWSTEPNAME = wsrows[0].WORKFLOWSTEPNAME
          qualityDeal.containerspecInfo.WORKFLOWSTEPID = wsrows[0].WORKFLOWSTEPID
          qualityDeal.containerspecInfo.WORKER = workers.join(',')
          qualityDeal.containerspecInfo.CHECKER = checker.join(',')
          const config = {
            url: `${ZSCheckUrl}?action=GetBigSmallData&workflowstepid=${wsrows[0].WORKFLOWSTEPID}&ContainerNo=${mrow.TOGETHERFLAG}`,
          };
          {
            const { tdata } = await commonFetch(config);
            qualityDeal.bigsmallList = tdata
          }
          const configf = {
            url: `${ZSCheckUrl}?action=GetUnit`,
          };
          {
            const { tdata } = await commonFetch(configf);
            qualityDeal.factoryList = tdata
          }

          qualityDeal.qualityDealDialogVisible = true
        }
        //7-1.【质量问题处置】---配套件行选择
        async function selectbigsmallListRow(row, column, event) {
          let mrow = currentContainerRow.value;
          qualityDeal.formData = row
          qualityDeal.formData.ProductFamilyName = mrow.PRODUCTFAMILYNAME
          qualityDeal.formData.MaterialTrademark = mrow.MATERIALTRADEMARK
          qualityDeal.formData.Part_RevID = mrow.PART_REVID
          const config = {
            url: `${ZSCheckUrl}?action=GetQulityQuestionDeal&productitemname=${row.PRODUCTNAME}&issueerpmalterialid=${row.ISSUEERPMATERIALID}&togetherflag=${mrow.TOGETHERFLAG}`,
          };
          const { tdata } = await commonFetch(config);
          if (tdata.value !== null) {
            let quality = tdata.value[0]
            qualityDeal.formData.qualityhistoryrecordid = quality.QUALITYHISTORYRECORDID
            qualityDeal.formData.UnqualifiedNum = quality.UNQUALIFIEDNUM
            qualityDeal.formData.CheckNO = quality.CHECKNO
            qualityDeal.formData.DUTYEMPLOYEEID = quality.DUTYEMPLOYEEID
            qualityDeal.formData.PartCategory = quality.PARTCATEGORY
            qualityDeal.formData.FactoryID = quality.FACTORYID
            qualityDeal.formData.problemNature = quality.PROBLEMNATURE
            qualityDeal.formData.UnqualifiedDescribe = quality.UNQUALIFIEDDESCRIBE
            qualityDeal.formData.IsKeyFeatures = quality.ISKEYFEATURES,
              qualityDeal.formData.IsImportantFeatures = quality.ISIMPORTANTFEATURES,
              qualityDeal.formData.IsDesignBasisFeatures = quality.ISDESIGNBASISFEATURES
          } else {
            qualityDeal.formData.qualityhistoryrecordid = ''
            qualityDeal.formData.UnqualifiedNum = ''
            qualityDeal.formData.CheckNO = ''
            qualityDeal.formData.PartCategory = '01'
            qualityDeal.formData.FactoryID = ''
            qualityDeal.formData.problemNature = '50'
            qualityDeal.formData.UnqualifiedDescribe = ''
            qualityDeal.formData.IsKeyFeatures = 0,
              qualityDeal.formData.IsImportantFeatures = 0
            qualityDeal.formData.IsDesignBasisFeatures = 0

          }

        }
        //7-2.【质量问题处置】---查询责任人
        async function GetEmployees(val) {
          if (val === '') {
            return //ElMessage.error('请输入关键字');
          }
          const config = {
            url: `${ZSCheckUrl}?action=GetEmployees&Name=${val}`,
          };
          const { tdata } = await commonFetch(config);
          qualityDeal.employeeList = tdata
        }

        //7-3.【质量问题处置】---确定保存操作
        async function handleSavequalityDeal() {
          let qualityDealData = qualityDeal.formData;
          qualityDealData.productName = qualityDeal.containerspecInfo.PRODUCTNAME
          qualityDealData.productItemName = qualityDealData.PRODUCTNAME
          qualityDealData.engineno = qualityDeal.containerspecInfo.MACHINE
          qualityDealData.togetherflag = qualityDeal.containerspecInfo.TOGETHERFLAG
          qualityDealData.mfgOrderName = qualityDeal.containerspecInfo.MFGORDERNAME
          qualityDealData.workflowstepid = qualityDeal.containerspecInfo.WORKFLOWSTEPID
          qualityDealData.IssueERPMaterialID = qualityDealData.ISSUEERPMATERIALID
          if (qualityDealData.qualityhistoryrecordid === undefined) {
            qualityDealData.qualityhistoryrecordid = ''
          }
          if (qualityDealData.productItemName === null || qualityDealData.productItemName === undefined) {
            return ElMessage.error('零件图号不能为空，请选择零件');
          }
          if (qualityDealData.UnqualifiedNum === '' || qualityDealData.UnqualifiedNum === undefined) {
            return ElMessage.error('不合格品数不能为空，请输入数量');
          }
          if (Number(qualityDealData.UnqualifiedNum) > Number(qualityDealData.QTYREQUIRED)) {
            return ElMessage.error('不合格品数不能大于总数，请重新输入数量');
          }
          if (qualityDealData.DUTYEMPLOYEEID === null || qualityDealData.DUTYEMPLOYEEID === undefined) {
            return ElMessage.error('责任者不能为空，请选择');
          }
          if (qualityDealData.UnqualifiedDescribe === '' || qualityDealData.UnqualifiedDescribe === undefined) {
            return ElMessage.error('不合格描述不能为空，请输入');
          }

          let formData = new FormData();
          formData.append("data", JSON.stringify([qualityDealData]))
          const config = {
            url: `${ZSCheckUrl}?action=SaveQulityQuestionDeal`,
            data: formData
          };
          const { Message, Result } = await commonFetch(config);
          if (Result) {
            ElMessage.success(Message)
          }
        }




        // 页面声明周期钩子
        onMounted(async () => {

          let incrementNumber = () => {
            setTimeout(incrementNumber, 3000);
            currentTime.value = dayjs().format('YYYY年MM月DD日  HH:mm');
          }

          setTimeout(incrementNumber, 0);

          // 查询当前用户信息，绑定给响应式变量 userInfo
          const uid = Decrypt(getParams('uid'));
          await getUserInfo({ url: `${FetchCommonUrl}`, method: 'getUserInfo', employeeid: uid });

          // 用户并不存在
          if (!userInfo.value.employeeid) {
            return ElNotification({ title: '错误', message: '用户不存在', type: 'error', duration: 0, });
          }

          const { factorycode, factoryid, employeeid } = userInfo.value;

          //装配厂
          const allowedFacotrys = ['603'];
          if (allowedFacotrys.filter(i => i === factorycode).length === 0) {
            return ElNotification({ title: '错误', message: '当前分厂暂不能使用该功能', type: 'error', duration: 0, });
          }
          //查询工时
          await getWorkTime();
          await handleContainerSearchBlur(1);
        })
        // 返回给页面使用的数据
        return {
          currentTime,//当前时间
          tabfirst,
          tabfirst1,
          clientHeight, inputHeight, tableHeight,
          formData,
          containerTableRef,
          queryContainerCheckData,//查询报工数据(方法)
          handleSizeChange,
          handleCurrentChange,
          containerList,//查询报工数据
          selectContainerRow,//任务单表格行点击事件（查询工序数据）
          currentContainerRow,
          specTableRef,
          stepTableRef,
          main,
          specList,//工序数据
          selectSpecChange,//工序勾选变动事件（查询工步信息）
          stepList,//工步数据
          dealscrap,//排故单、报废单信息

          worktimeInfo,//工时信息
          getWorkTime,//查询工时

          unqualified,//不合格申请申请
          selectcheckListRow,//检验任务--行单选事件
          selectbigsmallProductListRow,//配套件--行单选事件--查询集件信息
          selectunqualifiedbigsmallListRow,//配套件--行单选事件--查询集件信息行选择
          saveCheckResultData,//【检验提交】
          saveUnqualifiedData,//【不合格审理提交】
          SearchProductList,//查询件号信息
          selectProductInfo,//选择件号信息
          popoverRef,
          selectDefectsCode,
          selectLossSequence,



          handleNodeClick,//【文档查看】- 文档查看节点点击
          handleOpenDocumentClick,//【文档查看】-【查看文档】按钮点击
          documentViewDialogVisible,//文档查看弹出框
          treeData,//文档查看Tree数据
          documentList,//文档查看文件清单

          checkPoint,//实测值录入
          checkPointUrl,//检测项录入引用URL
          qualityLook,//质量问题查看
          qualityDeal,//质量问题处置
          GetEmployees,//查询人员信息
          handleContainerSpecCheck,//【检验】按钮点击
          handleCheckUnqualified,//【不合格审理申请】按钮点击
          handleCheckQualified,//【合格】按钮点击
          handlePupInputChechPoint,// 【实测值录入】按钮点击
          selectContainer,//【实测值录入】查询实测值及其录入结果
          selectcheckPointRow,//【实测值录入】实测值单选行事件
          selectcheckPointResultRow,//【实测值录入】实测值单选行事件
          saveCheckPointResult,//【实测值录入】保存按钮点击
          handleQualityProblemLook,//【质量问题查看】按钮点击
          handleQualityDeal,//【质量问题处置】按钮点击
          selectbigsmallListRow,//【质量问题处置】配套件行点击
          handleSavequalityDeal,//【质量问题处置】提交保存按钮
          handleSelectionCheckPointChange,//【实测值录入】实测值多选行事件
          checkPointTableRef,//检测项表格唯一ref
          splitDate,
          dateFormatter,
          userInfo,//当前用户信息
          searchObj,
          containerSearchScan,//扫卡查询【待报工、待检验】数据对象
          handleDocumentViewClick,//【文档查看】按钮点击
          handleUserInfoFlushClick,//刷新员工信息数据
          handleContainerSearchBlur,
          selectContainerMenu,
          qureyReset,
        }
      }
    };
    const app = createApp(App);
    app.use(ElementPlus, {
      locale: ElementPlusLocaleZhCn,
      //size: 'normal'
    });
    // 注册所有icon
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      switch (key) {
        case "View":
          app.component('icon-view', component)
          break;
        case "Menu":
          app.component('icon-menu', component)
          break;
        default:
          app.component(key, component)
          break;
      }
    }

    app.mount('#app');
  </script>
</body>

</html>